#ifndef LOGIN_V_COMMAND_IN_H_
#define LOGIN_V_COMMAND_IN_H_
#include "command.h"

#pragma pack(1)
namespace Cmd
{
        namespace LoginVerify
        {
                //  cmd declaration
                enum {
                        CMDIN_LOGIN             = 0x0010,       // 登录RecordServer验证指令
                        CMDIN_FORWARD           = 0x0011,	// 转发的指令
                        CMDIN_LOGINSERVER       = 0x0012,       // 与LoginServer交互的指令
                };
                enum { //CMDIN_LOGIN
                        SCMDIN_LOGIN                            = 0x0001,       // 请求登录RecordServer
                        SCMDIN_LOGIN_RESPONCE                   = 0x0002,       // 登录RecordServer返回
                };
                enum { //CMDIN_FORWARD
                        SCMDIN_FORWARD_RECORD                   = 0x0001,       // 转发到RecordServer的指令
                        SCMDIN_FORWARD_USER                     = 0x0002,	// RecordServer转发指令给用户
                };
                enum { //CMDIN_LOGINSERVER
                        SCMDIN_LS_RES_VERIFY_ACCOUNT            = 0x0002,       // LoginVerify->Login:返回验证用户帐号结果
                        SCMDIN_LS_REQ_VERIFY_HJ_ACCOUNT         = 0x0003,       // Login->LoginVerify:使用沪江帐号请求
                        SCMDIN_VERIFY_UNREGISTERED_REQ          = 0x0004,       // Login->LoginVerify:游客登录
                        SCMDIN_VERIFY_UNREGISTERED_RES          = 0x0005,       // LoginVerify->Login:返回验证结果
                };

                //	cmd definition
                struct stLoginCmd:t_NullCmd
                {
                        stLoginCmd():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN)
                        {
                                dest_type_ = LOGINVERIFYSERVER;
                                server_type_ = 0;
                                server_id_ = 0;
                        }
                        WORD dest_type_;
                        WORD server_type_;
                        DWORD server_id_;
                };
                struct stLoginResponce:t_NullCmd
                {
                        stLoginResponce():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN_RESPONCE)
                        {
                        }
                };

                struct stForwardRecord:t_NullCmd
                {
                        stForwardRecord():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_RECORD)
                        {
                                user_id_ = 0;
                                size_ = 0;
                        }
                        DWORD user_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize() const
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stForwardUser:t_NullCmd
                {
                        stForwardUser():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_USER)
                        {
                                user_id_ = 0;
                                size_ = 0;
                        }
                        DWORD user_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize() const
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stLVResVerifyAccount:
                        t_NullCmd
                {
                        stLVResVerifyAccount():
                                t_NullCmd(CMDIN_LOGINSERVER, SCMDIN_LS_RES_VERIFY_ACCOUNT)
                        {
                                temp_id_ = 0;
                                user_id_ = 0;
                                bzero(user_name_, sizeof(user_name_));
                                latest_version_ = 0;
                                force_upgrade_  = 0;
                                ret_code_ = eLoginRetCode_Fail;
                                bzero(st_, sizeof(st_));
                        }
                        DWORD temp_id_;
                        DWORD user_id_;
                        char user_name_[MAX_ACCOUNT_SIZE+1];
                        DWORD latest_version_;  //
                        BYTE force_upgrade_;    //0-no, 1-yes
                        BYTE ret_code_;         //eLoginRetCode
                        char st_[MAX_TOKEN32_SIZE+1];
                };
                struct stLVReqVerifyHJAccount:
                        t_NullCmd
                {
                        stLVReqVerifyHJAccount():
                                t_NullCmd(CMDIN_LOGINSERVER, SCMDIN_LS_REQ_VERIFY_HJ_ACCOUNT)
                        {
                                temp_id_ = 0;
                                bzero(account_, sizeof(account_));
                                bzero(passwd_, sizeof(passwd_));
                                account_[MAX_ACCOUNT_SIZE] = '\0';
                                passwd_[MAX_PASSWORD_SIZE] = '\0';
                                version_type_ = 0;
                                version_id_ = 0;
                                ip_ = 0;
                        }
                        DWORD temp_id_;
                        char account_[MAX_ACCOUNT_SIZE+1];
                        BYTE passwd_[MAX_PASSWORD_SIZE+1]; //passwd md5
                        BYTE version_type_;
                        DWORD version_id_;
                        DWORD ip_;
                };

                struct stVerifyUnregisteredReq:
                        t_NullCmd
                {
                        stVerifyUnregisteredReq():
                                t_NullCmd(CMDIN_LOGINSERVER, SCMDIN_VERIFY_UNREGISTERED_REQ)
                        {
                                temp_id_ = 0;
                                user_id_ = 0;
                                version_type_ = 0;
                                version_id_ = 0;
                                ip_ = 0;
                        }

                        uint32_t temp_id_;
                        uint32_t user_id_;
                        uint8_t version_type_;
                        uint32_t version_id_;
                        uint32_t ip_;
                };

                struct stVerifyUnregisteredRes:
                        t_NullCmd
                {
                        stVerifyUnregisteredRes():
                                t_NullCmd(CMDIN_LOGINSERVER, SCMDIN_VERIFY_UNREGISTERED_RES)
                        {
                                temp_id_ = 0;
                                user_id_ = 0;
                                latest_ver_ = 0;
                                force_update_ = 0;
                                ret_code_ = 0;
                        }

                        uint32_t temp_id_;
                        uint32_t user_id_;
                        uint32_t latest_ver_;
                        uint8_t force_update_;
                        uint8_t ret_code_;
                };
        }; //namespace LoginVerify
}; //namespace Cmd
#pragma pack() //pack(1)

#endif //LOGIN_V_COMMAND_H_
